//
//  SearchController.m
//  pocketmedicine
//
//  Created by student on 16/5/6.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "SearchController.h"
#import "SearchCell.h"
#import "GuoYaoZhunZiViewController.h"
#import "CodeViewController.h"
#import "DrugSearchViewController.h"
@interface SearchController()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property (strong,nonatomic)NSArray *list;
@end

@implementation SearchController


- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    self.list = @[@{@"Name":@"搜索",@"Image":@"magnifying-glass"},
                  @{@"Name":@"国药准字",@"Image":@"band-aid"},
                  @{@"Name":@"条形码",@"Image":@"lightning-bolt"}];
                  
    
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.list.count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 1)
    {
        GuoYaoZhunZiViewController *vc1 = [self.storyboard instantiateViewControllerWithIdentifier:@"GuoYaoVC"];
        [self presentViewController:vc1 animated:YES completion:nil];
        
    }else if (indexPath.row == 2)
    {
        CodeViewController *vc2 = [self.storyboard instantiateViewControllerWithIdentifier:@"CodeVC"];
         [self presentViewController:vc2 animated:YES completion:nil];
    }
     else
    {
        DrugSearchViewController *vc3 = [self.storyboard instantiateViewControllerWithIdentifier:@"SearchVC"];
         [self presentViewController:vc3 animated:YES completion:nil];
    }
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *d = self.list[indexPath.row];
    SearchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    cell.useLabel.text = d[@"Name"];
    cell.imageView.image = [UIImage imageNamed:d[@"Image"]];
    
    
    return cell;
}







@end
